import Cookies from "js-cookie";

const TokenKey = "Admin-Token";
const Industry = "Industry";
const SectionCode = "SectionCode";

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

//  获取行业分类
export function getIndustry() {
  let info = {};
  if (Cookies.get(Industry)) {
    info = JSON.parse(Cookies.get(Industry));
  }
  return info;
}

//  存储行业分类
export function setIndustry(info) {
  const userInfo = JSON.stringify(info);
  return Cookies.set(Industry, userInfo);
}

//  移除行业分类
export function removeIndustry() {
  return Cookies.remove(Industry);
}

//  获取标段代码
export function getSectionCode() {
  let info = {};
  if (Cookies.get(SectionCode)) {
    info = JSON.parse(Cookies.get(SectionCode));
  }
  return info;
}

//  设置标段代码
export function setSectionCode(info) {
  const userInfo = JSON.stringify(info);
  return Cookies.set(SectionCode, userInfo);
}

//  删除标段代码
export function removeSectionCode() {
  return Cookies.remove(SectionCode);
}
